package com.gitee.base.security.shiro;

import com.jagregory.shiro.freemarker.ShiroTags;
import freemarker.template.TemplateModelException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

import javax.annotation.PostConstruct;

/**
 * <li>shiro权限标签</li>
 * <li>使用方式：</li>
 * <pre class="code">
 * &lt;@shiro.hasPermission name="sys:staff:addOrEdit"&gt;
 * 		html代码
 * &lt;/@shiro.hasPermission&gt;
 * </pre>
 */
@Component
public class ShiroTagsFreeMarkerCfg {

    @Autowired
    private FreeMarkerConfigurer freeMarkerConfigurer;

    @PostConstruct
    public void setSharedVariable() throws TemplateModelException {
        freeMarkerConfigurer.getConfiguration().setSharedVariable("shiro", new ShiroTags());
    }
}